package com.hm.controller;


import com.hm.pojo.HmItem;
import com.hm.pojo.HmItemCat;
import com.hm.serivce.HmItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(value = "商品列表接口",tags = {"商品列表接口"})
public class HmItemController {

    @Autowired
    private HmItemService hmItemService;

    /**
     * 分类模块点击任意商品，显示右边商品列表
     * @param cat_id
     * @return
     */
    @RequestMapping(value = "/ShowRightItemList",method = RequestMethod.POST)
    @ApiOperation(value = "商品右边列表页面")
    public List<HmItem> ShowRightItemList(long cat_id,int sort_order){
        List<HmItem> list = hmItemService.ShowRightItemList(cat_id,sort_order);
        return list;
    }

    /**
     * 分类模块点击任意商品，显示左边商品列表
     * @param parent_id
     * @return
     */
    @RequestMapping(value = "/ShowLeftItemList",method = RequestMethod.POST)
    @ApiOperation(value = "商品左边列表页面")
    public List<HmItemCat> ShowLeftItemList(long parent_id){
        List<HmItemCat> list = hmItemService.ShowLeftItemList(parent_id);
        return list;
    }

    /**
     * 点击商品，进商品详情页面
     * @param id
     * @return
     */
    @RequestMapping(value = "/ShowItemDetails",method = RequestMethod.POST)
    @ApiOperation(value = "商品详情页面")
    public HmItem ShowItemDetails(long id){
        HmItem hmItem = hmItemService.ShowItemDetails(id);
        long parent_id = hmItemService.xxxx(hmItem.getCid());
        hmItem.setParent_id(parent_id);
        return hmItem;
    }

}
